<template>
  <div class="app">
    <div class="parent" style="width: 1530px;height: 100%;background-color: #f5f7f9">
      <!--头部-->
      <div class="header" style="box-shadow: 1px 1px 10px #9d9fa6; width: 100%;height: 66px;background-color: #ffffff">
        <!--title-->
        <div class="title" style="background-color: #545c64;height: 46px;width: 15%;padding-top: 20px;float: left">
          <span style="color: white;font-size: 1.2em;margin-left: 20px">爱企查后台管理</span>
        </div>
        <div class="right_t" style="float: right;margin-top: 20px;margin-right: 30px">
          <span style="margin-right: 50px;color: black">欢迎:{{ d.idCard }}</span>
          <span @click="loginout"><router-link style="text-decoration: none;color: black" :to="{ name: 'AdminL' }">退出登录</router-link></span>
        </div>
      </div>
      <!-- 管理端主体 -->
      <div class="admin_body">
        <!-- 左侧侧边栏 -->
        <div class="left">
          <el-menu
            style="height: 645px;"
            default-active="2"
            class="el-menu-vertical-demo"
            @open="handleOpen"
            @close="handleClose"
            background-color="#545c64"
            text-color="#fff"
            active-text-color="#ffd04b"
            :default-active="this.$route.path" router
          >
            <el-menu-item index="/Role" >
              <i class="el-icon-user"></i>
              <span slot="title">角色管理</span>
            </el-menu-item>
            <el-menu-item index="/User">
              <i class="el-icon-s-custom"></i>
              <span slot="title">用户管理</span>
            </el-menu-item>
            <el-menu-item index="/New">
              <i class="el-icon-s-comment"></i>
              <span slot="title">资讯管理</span>
            </el-menu-item>
            <el-menu-item index="/Company">
              <i class="el-icon-office-building"></i>
              <span slot="title">企业管理</span>
            </el-menu-item>
          </el-menu>
        </div>
        <!-- /左侧侧边栏 -->

        <!-- 右侧内容 -->
        <div class="right">
          <router-view></router-view>
        </div>
        <!-- /右侧内容 -->
      </div>
      <!-- /管理端主体 -->
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      d: {}
    };
  },
  methods: {
    handleOpen(key, keyPath) {
      console.log(key, keyPath);
    },
    handleClose(key, keyPath) {
      console.log(key, keyPath);
    },
    /*单个id查询用户*/
    findUserById(id) {
      this.updateFormVisible = true;
      let _this = this;
      console.log(id);
      this.$axios
        .get('http://localhost:8087/user/getUserById/' + id)
        .then(function(res) {
          _this.d = res.data;
        })
        .catch(function(err) {
          alert('查询失败');
        });
    },
    // 退出登录
    loginout(){
      removeItem('id')
    }
  },
  created() {
    this.findUserById(localStorage.getItem("id"));
  }
};
</script>

<style scoped>
.admin_body {
  display: flex;
  width: 1475px;
  height: 100%;
}
.left {
  width: 232px;
  height: 100%;
}
/deep/ .el-menu{
  border-right: solid 0px;
}
.right {
  width: 85%;
}
</style>
